package com.yueqian.system.controller;

import java.util.List;

import org.springframework.web.bind.annotation.*;

import com.yueqian.framework.entity.ResultEntity;
import com.yueqian.system.service.MenuService;
import com.yueqian.system.vo.req.MenuReqVO;
import com.yueqian.system.vo.res.MenuResVO;

import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author lxy
 * @since 2024-05-13
 */
@RestController
@RequestMapping("/menu")
@Slf4j
public class MenuController {


	@Resource
	private MenuService menuService;

	@GetMapping("/getDetail")
	public ResultEntity<MenuResVO> getDetail(@RequestParam(value = "id", required = false) Long id) {
		MenuResVO menuResVO = menuService.getDetail(id);
		return ResultEntity.success(menuResVO);
	}

	@PostMapping("/add")
	public ResultEntity<Long> add(@RequestBody MenuReqVO reqVO) {
		return ResultEntity.success(menuService.add(reqVO));
	}

	@GetMapping("/delete")
    public ResultEntity<Long> delete(@RequestParam("id") Long id) {
        return ResultEntity.ok(menuService.delete(id));
     }


	@GetMapping("/getMenus")
	public ResultEntity<List<MenuResVO>> getMenus(MenuReqVO reqVO) {
		return ResultEntity.success(menuService.getMenus(reqVO));
	}
}
